/**
 * Created by Administrator on 2016/8/1.
 */

var uuid = require('node-uuid');
var logger = require('../../utils/logHelper').helper;
var cartService = require('../service/cartService');

/**
 * @param req
 * @param res
 */




//确认订单页面
exports.comfirmorder = function(req, res) {
    var userid=req.query.userid;
    cartService.comfirmorder(userid,function(err, rows) {
        if(err)
        {
            res.send({success:false,msg:"查询失败"});
        }else{
            res.send({success:true,data:rows});
        }
    });
};


//待支付定金数据
exports.advancewait = function(req, res) {
    var reservearray = req.body.reservearray;
    cartService.advancewait(reservearray,function (err,data) {
        if(err){
            res.send({success:false,msg:"插入失败"});
        }else{
            res.send( {success: 1,data:data});
        }
    })
};


//确认订单支付定金
exports.payearnest = function(req, res) {
    var userid=req.query.userid;
    var orderno=req.query.orderno;
    var sid=req.query.sid;
    var source =req.query.way;
    var deposit =req.query.deposit;
    cartService.payearnest(userid,orderno,source,deposit,sid,function (err,data) {
        if(err){
            res.send({success:false,msg:"查询失败"});
        }else{
            res.send( {success: 1,data:data});
        }
    })
};

//购物车
exports.shoppingcart = function(req, res) {
    var userid=req.query.userid;
    cartService.shoppingcart(userid,function(err, rows) {
        if(err)
        {
            res.send({success:false,msg:"查询失败"});
        }else{
            res.send({success:true,data:rows});
        }
    });
};